<!--
Date: 2025-08-13
Copyright (c) 2025 Industrial Software Feature Database
-->
<template>
  <div class="elements">
    <Main v-if="showMain" @handleEvent="handleEvent" />
    <!-- 自然网格模型数据导入 -->
    <Import v-if="showNewElement" :tableName="tableName" @handleEvent="handleEvent"  />
    <List v-if="showBuildList" :tableName="tableName" @handleEvent="handleEvent" />
    <!-- 结果库数据导入 -->
    <ImportMaterial v-if="showNewMaterial" :modelId="modelId" @handleEvent="handleEvent" />
    <MaterialList v-if="showMaterialList" :modelId="modelId" @handleEvent="handleEvent" />
    <!-- op2结果库数据导入 -->
    <ResultList v-if="showOp2List" @handleEvent="handleEvent" />
    <ResultImport v-if="showOp2Import" @handleEvent="handleEvent" />
  </div>
</template>
<script setup name="AcquisiteModel">
import Main from './components/Main.vue';
import List from './components/List.vue';
import Import from './components/Import.vue';
import MaterialList from './materialWarehouse/MaterialList.vue';
import ImportMaterial from './components/ImportMaterial.vue';
import ResultList from './op2/ResultList.vue';
import ResultImport from './op2/ResultImport.vue';
const tableName = ref('');
const modelId = ref('');
const showBuildList = ref(false);
const showNewElement = ref(false);
const showNewMaterial = ref(false);
const showMaterialList = ref(false)
const showMain = ref(true);
const showOp2List = ref(false);
const showOp2Import = ref(false);
const handleEvent = (data) => {
  if (data.component === 'Import') {
    showBuildList.value = false;
    showMain.value = false;
    tableName.value = data.tableName;
    showNewElement.value = true;
    showNewMaterial.value = false;
    showMaterialList.value = false;
    showOp2List.value = false;
    showOp2Import.value = false;
  }
  if (data.component === 'List') {
    showNewElement.value = false;
    showMain.value = false;
    tableName.value = data.tableName;
    showBuildList.value = true;
    showNewMaterial.value = false;
    showMaterialList.value = false;
    showOp2List.value = false;
    showOp2Import.value = false;
  }
  if (data.component === 'Main') {
    showNewElement.value = false;
    showMain.value = true;
    showBuildList.value = false;
    showNewMaterial.value = false;
    showMaterialList.value = false;
    showOp2List.value = false;
    showOp2Import.value = false;
  }
  if (data.component === 'ImportMaterial') {
    modelId.value = data.modelId;
    showNewElement.value = false;
    showMain.value = false;
    showBuildList.value = false;
    showNewMaterial.value = true;
    showMaterialList.value = false;
    showOp2List.value = false;
    showOp2Import.value = false;
  }
  if (data.component === 'MaterialList') {
    modelId.value = data.modelId;
    showNewElement.value = false;
    showMain.value = false;
    showBuildList.value = false;
    showNewMaterial.value = false;
    showMaterialList.value = true;
    showOp2List.value = false;
    showOp2Import.value = false;
  }
  if (data.component === 'Op2List') {
    showNewElement.value = false;
    showMain.value = false;
    showBuildList.value = false;
    showNewMaterial.value = false;
    showMaterialList.value = false;
    showOp2List.value = true;
    showOp2Import.value = false;
  }
  if (data.component === 'ImportOp2') {
    showNewElement.value = false;
    showMain.value = false;
    showBuildList.value = false;
    showNewMaterial.value = false;
    showMaterialList.value = false;
    showOp2List.value = false;
    showOp2Import.value = true;
  }
};
onMounted(() => {
  // tableName.value = route.query?.tableName || '';
})
</script>
<style lang="scss" scoped>
.elements {
  height: calc(100vh - 84px);
  width: 100%;
}
</style>